﻿using System.Drawing;

namespace ImageProcess.Model
{
    /// <summary>
    /// 矩形匹配结构
    /// </summary>
    public class RectangleMatch
    {
        /// <summary>
        /// ID编号
        /// </summary>
        public string Id { get; set; } = Guid.NewGuid().ToString();

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 给定的匹配阈值
        /// </summary>
        public double Threshold { get; set; } = 0.65f;

        /// <summary>
        /// 返回的匹配度结果
        /// </summary>
        public double Score { get; set; } = 0f;

        /// <summary>
        /// 原图大小
        /// </summary>
        public Size OriginalSize { get; set; } = Size.Empty;

        /// <summary>
        /// 矩形匹配结构的尺寸
        /// </summary>
        public Rectangle Rect { get; set; }

        public RectangleMatch(Point location, Size size, double threshold = 0.65f)
        {
            Threshold = threshold;
            Rect = new Rectangle(location, size);
        }

        public RectangleMatch(int x, int y, int width, int height, double threshold = 0.65f)
        {
            Threshold = threshold;
            Rect = new Rectangle(x, y, width, height);
        }

        public override string ToString()
        {
            return $"{{X={Rect.X},Y={Rect.Y},Width={Rect.Width},Height={Rect.Height}}}";
        }
    }
}
